package com.sss.hloster0103;

import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

public class ComparableTestDriver {

	public static void main(String[] args) {
		test01();
	}

	private static void test01() {
		Set set = new TreeSet();
		set.add(new Student("张三", "001", 21, 80));
		set.add(new Student("李四", "002", 22, 70));
		set.add(new Student("王五", "003", 20, 90));
		System.out.println("增强型的for循环遍历取出HashSet集合中的元素：");
		for (Object object : set) {
			System.out.println(((Student) object).getStuName() + ":" + ((Student) object).getStuScore());	
			}
		System.out.println("使用迭代器循环遍历取出HashSet集合中的元素：");
		// 获取当前集合对象的迭代器对象
		Iterator it = set.iterator();
		while (it.hasNext()) {
			System.out.println(it.next());
		}
	}
}
